package tmproject.hlhj.fhp.cartrans.modules

import android.content.Context
import com.example.mymvp.BaseModule
import com.lzy.okgo.model.Response
import tmproject.hlhj.fhp.cartrans.http.Apis
import tmproject.hlhj.fhp.cartrans.http.BaseObserver
import tmproject.hlhj.fhp.cartrans.http.LoadingAction
import tmproject.hlhj.fhp.cartrans.javaBean.AboutUsBean
import tmproject.hlhj.fhp.cartrans.javaBean.BaseBean
import tmproject.hlhj.fhp.cartrans.utils.SpHelper

/**
 * Created by Never Fear   on 2018\8\29 0029.
Never More....
 */
class AboutUsModule :BaseModule {
    var listener:OnUsListener?=null

    fun getUs(c:Context){
        Apis.getAboutUs(SpHelper.getToken(c))
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :BaseObserver<Response<AboutUsBean>>(c){
                                override fun failed(e: Throwable?) {
                                }

                                override fun httpSuccess(t: Response<AboutUsBean>) {
                                    listener?.gotUsInfo(t.body())
                                }

                                override fun httpErroCode(baseBean: BaseBean) {
                                }
                            })
                }
    }

    interface OnUsListener{
        fun gotUsInfo(aboutUsBean: AboutUsBean)
    }
}